<?php


class Framework_DB_Table_SiteUser extends Framework_DB_Table_Common {

	public $tableName = 'SiteUser';
	
	public function __construct($db) {
   		
   		// Columns
   		$this->col = array(
	   		// Primary Key
	        'idSiteUser'  => array(
	              'type'  => 'integer',
	           'require'  => true
	        ),
	        // Foreign Key
	        'idOwner'     => array(
	           'type'     => 'integer'
	        ),
	        

	        'siteDomain'   => array(
	             'type'   => 'varchar',
	             'size'   => 255
	        ),
	         
	        'avatarURL'    => array(
	            'type'    => 'varchar',
	            'size'    => 255
	        ),
	        
	        'userName'    => array(
	            'type'    => 'varchar',
	            'size'    => 255
	        ),

	        'blurb'   => array(
	        	 'type'   => 'clob'
	        ),
	        	
	        'dateLastLogin' => array(
	        	'type'    => 'integer'
	        ),
	       
	        'publicKey'   => array(
	        	 'type'   => 'clob'
	        )
	        
	    );
	    
	    // Indexes
	    $this->idx = array(
	    	'idSiteUser' =>  'primary',
	    	'idOwner' =>  'normal'
	    );
	    	
	    $this->auto_inc_col = 'idSiteUser';
   		
   		parent::__construct($db);
   }
   
 // Populate upon creation
   public function create($flag)
   {
   		
   		$result = parent::create($flag);
   	
   		if($result == true){
   			$this->insert(array('idSiteUser' => 0,'userName' => 'Anonymous'));
   		}
   		
   		return $result;
   	
   }
	
	
}

?>